import request from './requests.js'
import Cookies from 'js-cookie'
import {
	select_all_odd_url
} from "./setting.js"

import {
	Toast
} from 'vant'

import {
	getLocalTime
} from "./date.js"

import {
	select_all_duty_warehouse_ship
} from "./duty_warehouse_ship.js"
import {
	select_all_class_ship
} from "./duty_class_ship.js"




export function get_duty_warehouse_ship(callBack) {

	let duty_id = Cookies.get('duty_id')

	let warehouse_list = []
	let warehouse_id_list = []

	select_all_duty_warehouse_ship(

		(res) => {
			// console.log(res)

			for (let i = 0; i < res.length; i++) {
				if (duty_id == res[i].duty_id) {
					warehouse_list.push(res[i])
					warehouse_id_list.push(res[i].warehouse_id)
				}
			}
			
			callBack({
				warehouse_list: warehouse_list,
				warehouse_id_list: warehouse_id_list
			})
		}

	)

	

}





export function get_duty_ship() {

	let duty_id = Cookies.get('duty_id')

	let class_list = []
	let class_id_list = []
	let warehouse_list = []
	let warehouse_id_list = []

	select_all_class_ship(

		(res) => {
			// console.log(res)
			for (let i = 0; i < res.length; i++) {
				if (duty_id == res[i].duty_id) {
					class_list.push(res[i])
					class_id_list.push(res[i].class_id)
				}
			}
		}

	)

	select_all_duty_warehouse_ship(

		(res) => {
			// console.log(res)

			for (let i = 0; i < res.length; i++) {
				if (duty_id == res[i].duty_id) {
					warehouse_list.push(res[i])
					warehouse_id_list.push(res[i].warehouse_id)
				}
			}
		}

	)


	return {
		class_list: class_list,
		class_id_list: class_id_list,
		warehouse_list: warehouse_list,
		warehouse_id_list: warehouse_id_list,
	}



}
